//
//  MarketHeaderView.m
//  Mtime2.0
//
//  Created by 凉气的Mac on 16/9/18.
//  Copyright © 2016年 凉气的Mac. All rights reserved.
//

#import "MarketHeaderView.h"

#import "MarketHeaderViewCell.h"

static NSString *reuserId = @"cell";

@interface MarketHeaderView ()<UICollectionViewDataSource>

@property(nonatomic,weak) UICollectionViewFlowLayout *flow;

@end

@implementation MarketHeaderView


-(instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout{

    if (self = [super initWithFrame:frame collectionViewLayout:layout]) {
        
        self.flow = (UICollectionViewFlowLayout *)layout;
        
        [self setupUI];
    }
    
    return self;
}


-(void)layoutSubviews{
    
    [super layoutSubviews];

    self.flow.itemSize = self.size;
    
    self.flow.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    self.flow.minimumLineSpacing = 0;
    
    self.flow.minimumInteritemSpacing = 0;

}

-(void)setupUI{
    
    self.dataSource = self;
    
    [self registerClass:[MarketHeaderViewCell class] forCellWithReuseIdentifier:reuserId];
    
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{

    return 1;

}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{

    return 5;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

    MarketHeaderViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuserId forIndexPath:indexPath];
    
    return cell;

}
@end


















